﻿/// <reference path="../../Scripts/jquery-1.4.1-vsdoc.js">

        var isCountryTextBoxMust = true;
        var isProvinceTextBoxMust = false;
        var wtmkCountryName;

        $(document).ready(function () {
            countryTextBox = $('.countrynametext');
            provinceTextBox = $('.provnametext');
            wtmkCountryName = $find('wtmkCountryName');
            ShowCountryNameTextBox($('.CountryDropDown').val());
            $('.datepicker').datepicker({ 
                changeMonth: true,
                changeYear: true,
                showAnim: ''
            });
        });

        

        function CheckBirthdate() {
            var s = $(".birthdatetext")[0].value;
            var selectedBirthdate = new Date(s);
            var today = new Date();
            var diff = Math.floor((today - selectedBirthdate) / (86400000));
            if (diff <= 0) {
                alert(s + " 不是正确的生日，请重新选择。");
                return false;
            }
        }

        function CheckCountryName(s, args) {
            if (isCountryTextBoxMust) {
                if (countryTextBox.hasClass('textboxwatermark')) {
                    args.IsValid = false;
                }
            }
        }

        function CheckProvinceName(s, args) {
            if (isProvinceTextBoxMust) {
                if (provinceTextBox.hasClass('textboxwatermark')) {
                    args.IsValid = false;
                }
            }
        }
        
        
        function ShowCountryNameTextBox(countryNameSelected) {
            var bool = countryNameSelected == "";
            var provinceDropdownList = $(".ddprovince");

            if (bool) {
                // other countries
//                provinceDropdownList.css('display', 'none');
                countryTextBox.show();
                $('#defaultprovince').hide();
                $('#customprovince').show();
//                provinceTextBox.css('display', '');
//                countryTextBox.val("");
//                provinceTextBox.val("");
//                provinceTextBox.focus();
//                countryTextBox.focus();
                isCountryTextBoxMust = true;
                isProvinceTextBoxMust = true;

            }
            else {
                $('#defaultprovince').show();
                $('#customprovince').hide();
                countryTextBox.hide();
                isCountryTextBoxMust = false;
                isProvinceTextBoxMust = false;
            }
        }